using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using umbraco.cms.businesslogic.web;
using umbraco.cms.businesslogic.member;

namespace umbDashboard
{
	/// <summary>
	/// Summary description for WebForm1.
	/// </summary>
	public partial class WebForm1 : System.Web.UI.Page
	{
	
		protected void Page_Load(object sender, System.EventArgs e)
		{

if (Member.GetCurrentMember() != null) 
{
//	Member.RemoveMemberFromCache(Member.GetCurrentMember())
	// Member is logged in - do whatever you like...
}

			DocumentType dt = DocumentType.GetByAlias("nyhedside");
			umbraco.BusinessLogic.User u = new umbraco.BusinessLogic.User(0);
			System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("dynamic.mdb") + ";User Id=admin;Password=;");
			conn.Open();
			System.Data.OleDb.OleDbDataReader dr = new System.Data.OleDb.OleDbCommand("SELECT News.* FROM News WHERE (((News.NewsCategoryID)=1));", conn).ExecuteReader();
			while (dr.Read())
			{
				Document nyt = Document.MakeNew(dr["NewsHeading"].ToString(), dt, u, 1201);
				nyt.getProperty("indhold").Value = dr["NewsText"].ToString().Replace("<P align=left>&nbsp;</p>\n<P align=left></p>", "").Replace("<P align=left>&nbsp;</p>", "");
				nyt.getProperty("manchet").Value = dr["NewsManchet"].ToString();
				Response.Write(dr["NewsHeading"].ToString() + "<br/>");
			}
			conn.Close();


		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    

		}
		#endregion

protected void Button1_Click(object sender, System.EventArgs e)
{
	if (Page.IsValid) 
	{
		Member m = Member.GetMemberFromLoginNameAndPassword(TextBox1.Text, TextBox2.Text);
		
		if (m != null) 
		{
			// We add the member to the cache and then it's logged in
			Member.AddMemberToCache(m);

			// Let's add the member name to a label to tell that the member is logged in:
			Label1.Text = "You're logged in as " + m.Text;
		}
	}
}
	}
}
